package com.koron.css2.clientCenter.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.clientCenter.bean.InfoPubBean;
import com.koron.css2.clientCenter.bean.NoticeBean;
import com.koron.css2.clientCenter.mapper.NoticeMapper;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.serviceManage.utils.CommonUtils;
import com.koron.css2.serviceManage.utils.JsonUtils;
import com.koron.util.Constant;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

/**
 * 通知公告发布流程回调处理
 * 
 * @author 杨嘉慧
 *
 */
public class NoticePublish implements ServerInterface {

	@Override
	public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
		InfoPubBean infoPub = null;
		try {
			NoticeBean notice = JsonUtils.objectToPojo(req.getData(), NoticeBean.class);
			NoticeMapper noticeMapper = factory.getMapper(NoticeMapper.class);
			NoticeBean noticePublish = new NoticeBean();
			noticePublish.setId(notice.getId());
			noticePublish.setReleaseName(userInfo.getUserInfo().getName());
			noticePublish.setReleaseTime(CommonUtils.getCurrentTime());
			noticeMapper.noticeUpdate(noticePublish);
			return MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "发布成功", Void.class);
		} catch (Exception e) {
			logger.error("通知公告发布失败" + e.getMessage(), e);
			return MessageBean.create(Constant.MESSAGE_INT_FAIL, "通知公告发布失败", null);
		}
	}

}
